<template>
    <div class="goods-list">

        <div class="header-banner">
            <img class="banner-img" src="../../assets/xpsf.png" alt="新品首发">
            <h1 class="banner-title">新品首发</h1>
            <van-icon name="arrow-left" class="back-btn" @click="$router.go(-1)" />
        </div>

        <van-cell v-for="item in newGoodsList" :key="item.id" class="goods-item">
            <div class="goods-container">
                <div class="goods-image">
                    <img :src="item.picUrl" />
                </div>
                <div class="goods-right">
                    <div class="goods-name">{{ item.name }}</div>
                    <div class="goods-brief">{{ item.brief }}</div>
                    <div class="goods-price">
                        <span class="current-price">¥{{ item.retailPrice }}</span>
                        <span class="original-price">¥{{ item.counterPrice }}</span>
                    </div>
                </div>
            </div>
        </van-cell>
    </div>
</template>

<script setup>
import { ref, onMounted } from "vue";
import { getmorexpsf } from "@/api/home";

const newGoodsList = ref([]);

onMounted(async () => {
    const response = await getmorexpsf();
    newGoodsList.value = response.data.list;
});
</script>

<style scoped>
.goods-list {
    padding: 0 0 10px 0;
    background-color: #f7f8fa;
    min-width: 78vh
}

.header-banner {
    position: relative;
    width: 100%;
    margin-bottom: 10px;
}

.banner-img {
    width: 100%;
    display: block;
}

.banner-title {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 40px;
    font-weight: bold;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    margin: 0;
}


.back-btn {
    position: absolute;
    top: 12px;
    left: 12px;
    color: white;
    font-size: 20px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 50%;
    padding: 8px;
    z-index: 1;
}

.goods-item {
    padding: 0 !important;
}

.goods-container {
    display: flex;
    width: 100%;
    padding: 12px;
    align-items: flex-start;
}

.goods-image {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    margin-right: 12px;
}

.goods-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
}

.goods-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.goods-name {
    font-size: 15px;
    font-weight: 500;
    color: #333;
    margin-bottom: 4px;
    line-height: 1.4;
    text-align: left;
}

.goods-brief {
    font-size: 12px;
    color: #999;
    line-height: 1.4;
    margin-bottom: 8px;
    text-align: left;
}

.goods-price {
    display: flex;
    align-items: center;
    text-align: left;
}

.current-price {
    font-size: 16px;
    color: #ee0a24;
    font-weight: bold;
}

.original-price {
    font-size: 12px;
    color: #999;
    text-decoration: line-through;
    margin-left: 6px;
}
</style>